/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.isn.atencionemergencia.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author pool
 */
@Entity
@Table(name = "especie")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Especie.findAll", query = "SELECT e FROM Especie e"),
    @NamedQuery(name = "Especie.findByCodEspeci", query = "SELECT e FROM Especie e WHERE e.codEspeci = :codEspeci"),
    @NamedQuery(name = "Especie.findByDescEspece", query = "SELECT e FROM Especie e WHERE e.descEspece = :descEspece")})
public class Especie implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Cod_Especi", columnDefinition="CHAR(5) unsigned")
    private String codEspeci;
    @Column(name = "Desc_Espece")
    private String descEspece;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codEspeci")
    private Collection<AnimalMordedor> animalMordedorCollection;

    public Especie() {
    }

    public Especie(String codEspeci) {
        this.codEspeci = codEspeci;
    }

    public String getCodEspeci() {
        return codEspeci;
    }

    public void setCodEspeci(String codEspeci) {
        this.codEspeci = codEspeci;
    }

    public String getDescEspece() {
        return descEspece;
    }

    public void setDescEspece(String descEspece) {
        this.descEspece = descEspece;
    }

    @XmlTransient
    public Collection<AnimalMordedor> getAnimalMordedorCollection() {
        return animalMordedorCollection;
    }

    public void setAnimalMordedorCollection(Collection<AnimalMordedor> animalMordedorCollection) {
        this.animalMordedorCollection = animalMordedorCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codEspeci != null ? codEspeci.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Especie)) {
            return false;
        }
        Especie other = (Especie) object;
        if ((this.codEspeci == null && other.codEspeci != null) || (this.codEspeci != null && !this.codEspeci.equals(other.codEspeci))) {
            return false;
        }
        return true;
    }
    
}
